package com.jzo2o.market.controller.operation;


import com.jzo2o.common.model.PageResult;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController("operationActivityController")
@RequestMapping("/operation/activity")
@Api(tags = "运营端-活动相关接口")
public class ActivityController {
    @Resource
    private IActivityService activityService; // 活动服务

    /**
     * 保存优惠券活动接口
     * 作用：新增或修改一个活动信息
     */
    @PostMapping("/save")
    @ApiOperation(value = "保存优惠券活动接口")
    public void saveActivity(@RequestBody ActivitySaveReqDTO activitySaveReqDTO) {
        activityService.saveActivity(activitySaveReqDTO);
    }

    /**
     * 分页查询优惠券活动
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询优惠券活动")
    public PageResult<ActivityInfoResDTO> queryForPage(ActivityQueryForPageReqDTO activityQueryForPageReqDTO) {
        return activityService.queryForPage(activityQueryForPageReqDTO);
    }

    /**
     * 查询优惠券活动详情
     */
    @GetMapping("/{id}")
    @ApiOperation("查询优惠券活动详情")
    public ActivityInfoResDTO getDetail(@PathVariable("id") Long id) {
        return activityService.queryById(id);
    }

    /**
     * 活动撤销
     */
    @PostMapping("/revoke/{id}")
    @ApiOperation("活动撤销")
    public void revoke(@PathVariable("id") Long id) {
        activityService.revoke(id);
    }

}
